<?php defined('SYSPATH') or die('No direct script access.');

class Date extends Kohana_Date {
	
	public static function format($time, $format = NULL)
	{
		if ($format === NULL)
			$format = Kohana::$config->load('date.format');
		
		return date($format, $time);
	}
	
	public static function format_timezone($time, $format = NULL, $timezone = NULL)
	{
		if ($timezone === NULL)
			$timezone = Kohana::$config->load('date.timezone');
		
		$offset = new DateTime(date('Y-m-d H:i:s', $time), new DateTimeZone(kohana::$config->load('date.timezone')));
		$offset = $offset->getOffset();
		
		$time = $time + $offset;
		
		return Date::format($time, $format);
	}
	
}
